package com.mine.spring.manager;

import com.mine.spring.utils.ConnectionUtils;

import java.sql.SQLException;

public class TransactionManager {

    private ConnectionUtils connectionUtil;

    public void setConnectionUtil(ConnectionUtils connectionUtil) {
        this.connectionUtil = connectionUtil;
    }

    //v2
    // 开启手动事务控制
    public void beginTransaction() throws SQLException {
        connectionUtil.getCurrentThreadConn().setAutoCommit(false);
    }


    // 提交事务
    public void commit() throws SQLException {
        connectionUtil.getCurrentThreadConn().commit();
    }


    // 回滚事务
    public void rollback() throws SQLException {
        connectionUtil.getCurrentThreadConn().rollback();
    }
}
